﻿using Tele.DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Migrations;

namespace Tele.db
{
    public static class Seeder
    {
        public static void Seed(ApplicationDbContext db, bool seedTVShows = true, bool seedCharacters = true)
        { 
        
            if (seedTVShows)
            {
                //seed TVShow
                db.TVShows.AddOrUpdate(
                    p => p.Title,
                    new TVShow { Title = "Game of Thrones", Image = "http://cdn.screenrant.com/wp-content/uploads/Game-of-Thrones-Season-4-Logo.jpg", YearsActive = "2011 - current" },
                    new TVShow { Title = "Mad Men", Image = "http://socialsolutionscollective.com/wp-content/uploads/2013/03/mad-men-logo.jpg?bea18b", YearsActive = "2007 - current"},
                    new TVShow { Title = "True Detective", Image = "http://schmoesknow.com/wp-content/uploads/2014/07/true-detective-13.jpg", YearsActive = "2014 - current" },
                    new TVShow { Title = "Hannibal", Image = "http://spinoff.comicbookresources.com/wp-content/uploads/2013/02/Hannibal-NBC-Poster-2012-300x375.jpeg", YearsActive = "2013 - current" },
                    new TVShow { Title = "The Walking Dead", Image = "http://dnmmagazinedotcom.files.wordpress.com/2013/02/logo1.jpg?w=459&h=315&crop=1", YearsActive = "2010 - current" }
                    );
                db.SaveChanges();
            }
            if (seedCharacters)
            {
                db.Characters.AddOrUpdate(
                    p => p.Name,
                    new Character { Name = "Tyrion Lannister", Photo = "http://upload.wikimedia.org/wikipedia/en/5/50/Tyrion_Lannister-Peter_Dinklage.jpg", TVShowId = 1 },
                    new Character { Name = "Daenerys Targaryen", Photo = "http://upload.wikimedia.org/wikipedia/en/0/0d/Daenerys_Targaryen_with_Dragon-Emilia_Clarke.jpg", TVShowId = 1 },
                    new Character { Name = "Jon Snow", Photo = "http://upload.wikimedia.org/wikipedia/en/f/f0/Jon_Snow-Kit_Harington.jpg", TVShowId = 1 },
                    new Character { Name = "Eddard Stark", Photo = "http://upload.wikimedia.org/wikipedia/en/4/44/Ned_Stark_as_Portrayed_by_Sean_Bean_in_the_television_series_2011.jpg", TVShowId = 1 },
                    new Character { Name = "Rick Grimes", Photo = "http://upload.wikimedia.org/wikipedia/en/6/6b/Rick_Grimes.jpg", TVShowId = 5 },
                     new Character { Name = "Glenn Rhee", Photo = "http://upload.wikimedia.org/wikipedia/en/5/58/Glenn3_%28TV_Series%29.jpg", TVShowId = 5 },
                      new Character { Name = "Michonne", Photo = "http://upload.wikimedia.org/wikipedia/en/6/65/Michonne2_%28TV_Series%29.jpg", TVShowId = 5 },
                       new Character { Name = "The Governor", Photo = "http://upload.wikimedia.org/wikipedia/en/8/8b/The_Governor3_%28TV_Series%29.jpg", TVShowId = 5 },
                       new Character { Name = "Don Draper", Photo = "http://upload.wikimedia.org/wikipedia/en/7/7b/Don_Draper_Wiki.jpg", TVShowId = 2 },
                       new Character { Name = "Peggy Olson", Photo = "http://upload.wikimedia.org/wikipedia/commons/1/1e/Elisabeth_Moss_LF.jpg", TVShowId = 2 },
                       new Character { Name = "Roger Sterling", Photo = "http://upload.wikimedia.org/wikipedia/en/4/42/Roger_Sterling.jpg", TVShowId = 2 },
                       new Character { Name = "Joan Holloway", Photo = "http://upload.wikimedia.org/wikipedia/en/d/db/Joan_Holloway_Wiki.jpg", TVShowId = 2 },
                       new Character { Name = "Rustin Cohle", Photo = "https://lh3.googleusercontent.com/-63sHZKRhlgE/Uxjtjd51I7I/AAAAAAACon8/b_jDL3FgrW4/w640-h400-p-k/matthew-mcconaughey-explains-the-four-stages-of-rustin-cohle-in-true-detective-social.jpg", TVShowId = 3 },
                       new Character { Name = "Martin Hart", Photo = "http://img2.wikia.nocookie.net/__cb20140225071209/true-detective/images/a/ad/Martin_Hart_2012.jpg", TVShowId = 3 },
                       new Character { Name = "Maggie Hart", Photo = "http://1.bp.blogspot.com/-pO978tKb85A/UwuA6V1yLQI/AAAAAAAADUg/FTFIueGgFxo/s1600/maggie-interview-450.jpg", TVShowId = 3 },
                       new Character { Name = "Hannibal Lecter", Photo = "http://i.telegraph.co.uk/multimedia/archive/02553/hannibal1_2553735b.jpg", TVShowId = 4 },
                       new Character { Name = "Will Graham", Photo = "http://37.media.tumblr.com/e421fadaaa8f05df6a34d12ebc827e65/tumblr_miufuetsPe1rvs9wso1_500.jpg", TVShowId = 4 },
                       new Character { Name = "Alana Bloom", Photo = "http://img3.wikia.nocookie.net/__cb20130610030541/hannibalpedia/images/0/09/1x06_AlanaBloom.jpg", TVShowId = 4 }
                       );
                db.SaveChanges();
            }
        }
    }
}
